home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dr. Windows 3
/
dr win3.zip
/
dr win3
/
UTILITY1
/
MSWSRC35.ZIP
/
LOGO.H
< prev
next >
Wrap
C/C++ Source or Header
|
1993-09-27
|
14KB
|
420 lines
/*
* logo.h logo header file dvb
*
* Copyright (C) 1989 The Regents of the University of California
* This Software may be copied and distributed for educational,
* research, and not for profit purposes provided that this
* copyright and statement are included in all such copies.
*
*/
/* #define ecma /* for European extended character set using parity bit */
/* #define unix /* This should be done automatically by gcc! */
/* #define ultrix /* no usleep */
#ifdef THINK_C
#define mac
#endif
#ifdef __TURBOC__
#define ibm
#endif
#ifdef __ZTC__
#define ibm
#endif
#ifdef unix
#ifndef NOGRAPH
#define x_window /* turn this off for no graphics */
#endif
#endif
#ifdef vax
#define bsd
#endif
#ifdef sun
#define bsd
#endif
/* #define SYSV */ /* turn this on for inferior AT&T brand Unix */
#include <stdio.h>
#include <string.h>
#include <signal.h>
#ifndef mips
#include <stdlib.h>
#else
#include <sys/types.h>
#include <malloc.h>
extern char *getenv();
#endif
#ifdef ibm
#include <dos.h>
#endif
#ifdef mac
#define check_throwing (check_mac_stop() || stopping_flag == THROWING)
#else
#ifdef ibm
#define check_throwing (check_ibm_stop() || stopping_flag == THROWING)
#else
#define check_throwing (stopping_flag == THROWING)
#endif
#endif
typedef enum {wrapmode, fencemode, windowmode} mode_type;
#define WORDSIZE 32 /* bits per int */
#define NIL (NODE *) 0
#define UNBOUND Unbound
#define UNDEFINED Unbound
#define END_OF_LIST (NODE *) 2
#define HASH_LEN 1021 /* a prime number */
#define SEG_SIZE 1000 /* 1 for debugging internal leaks */
//#define MAX_PHYS_LINE 5000
//#define GCMAX 8192
#define MAX_NUMBER 50 /* max number of digits in a float */
#define MAX_BUFFER_SIZE 256
#define PREFIX_PRIORITY 2
#define MACRO_PRIORITY 1
#define TAIL_PRIORITY 0
typedef short NODETYPES;
/* Note that some of these values are used twice; they must be
* distinguishable by the other bits used with them. */
#define NT_TREE (NODETYPES)0100000
#define NT_EMPTY (NODETYPES)040000
#define NT_AGGR (NODETYPES)020000
#define NT_LIST (NODETYPES)010000
#define NT_RUNP (NODETYPES)004000
#define NT_ARRAY (NODETYPES)002000
#define NT_WORD (NODETYPES)001000
#define NT_NUMBER (NODETYPES)000400
#define NT_FLOAT (NODETYPES)000200
#define NT_CONT (NODETYPES)000200
#define NT_PRIM (NODETYPES)000100
#define NT_INFIX (NODETYPES)000040
#define NT_LINE (NODETYPES)000040
#define NT_VBAR (NODETYPES)000040
#define NT_STRING (NODETYPES)000020
#define NT_BACKSL (NODETYPES)000010
#define NT_PUNCT (NODETYPES)000004
#define NT_TAILFORM (NODETYPES)000004
#define NT_COLON (NODETYPES)000002
#define NT_MACRO (NODETYPES)000002
#define NT_CASEOBJ (NODETYPES)000001
#define PNIL (NODETYPES)(NT_EMPTY|NT_AGGR|NT_LIST)
#define PUNBOUND (NODETYPES)0
#define CONS (NODETYPES)(NT_AGGR|NT_LIST)
#define STRING (NODETYPES)(NT_WORD|NT_STRING)
#define INT (NODETYPES)(NT_WORD|NT_NUMBER)
#define FLOAT (NODETYPES)(NT_WORD|NT_NUMBER|NT_FLOAT)
#define PRIM (NODETYPES)(NT_PRIM)
#define MACRO (NODETYPES)(NT_PRIM|NT_MACRO)
#define TAILFORM (NODETYPES)(NT_PRIM|NT_TAILFORM)
#define CASEOBJ (NODETYPES)(NT_WORD|NT_CASEOBJ)
#define INFIX (NODETYPES)(NT_PRIM|NT_INFIX)
#define TREE (NODETYPES)(NT_AGGR|NT_LIST|NT_TREE)
#define RUN_PARSE (NODETYPES)(NT_AGGR|NT_LIST|NT_RUNP)
#define QUOTE (NODETYPES)(NT_WORD|NT_PUNCT)
#define COLON (NODETYPES)(NT_WORD|NT_PUNCT|NT_COLON)
#define BACKSLASH_STRING (NODETYPES)(NT_WORD|NT_STRING|NT_BACKSL)
#define VBAR_STRING (NODETYPES)(NT_WORD|NT_STRING|NT_BACKSL|NT_VBAR)
#define ARRAY (NODETYPES)(NT_AGGR|NT_ARRAY)
#define LINE (NODETYPES)(NT_LINE|NT_LIST|NT_AGGR)
#define CONT (NODETYPES)(NT_CONT|NT_LIST)
#define aggregate(nd) (nodetype(nd) & NT_AGGR)
#define is_cont(nd) (nodetype(nd) == CONT)
#define is_list(nd) (nodetype(nd) & NT_LIST)
#define is_tree(nd) (nodetype(nd) & NT_TREE)
#define is_string(nd) (nodetype(nd) & NT_STRING)
#define is_number(nd) (nodetype(nd) & NT_NUMBER)
#define is_prim(nd) (nodetype(nd) & NT_PRIM)
#define is_word(nd) (nodetype(nd) & NT_WORD)
#define runparsed(nd) (nodetype(nd) & NT_RUNP)
#define backslashed(nd) (nodetype(nd) & NT_BACKSL)
#define is_tailform(nd) (nodetype(nd) == TAILFORM)
typedef enum { FATAL, OUT_OF_MEM, STACK_OVERFLOW, TURTLE_OUT_OF_BOUNDS,
BAD_DATA_UNREC, DIDNT_OUTPUT, NOT_ENOUGH, BAD_DATA, TOO_MUCH,
DK_WHAT, PAREN_MISMATCH, NO_VALUE, UNEXPECTED_PAREN, DK_HOW,
NO_CATCH_TAG, ALREADY_DEFINED, STOP_ERROR, ALREADY_DRIBBLING,
FILE_ERROR, IF_WARNING, SHADOW_WARN, USER_ERR, IS_PRIM,
NOT_INSIDE, DK_HOW_UNREC, NO_TEST, UNEXPECTED_BRACKET,
UNEXPECTED_BRACE, BAD_GRAPH_INIT, ERR_MACRO,
DK_WHAT_UP, AT_TOPLEVEL, APPLY_BAD_DATA} ERR_TYPES;
typedef int BOOLEAN;
#define FALSE 0
#define TRUE 1
#define even_p(x) !(x & 0x1)
#define FIXNUM long
#define FLONUM double
#define MAXINT 0x7fffffffL
#define SAFEINT 0x00003fff /* safe to multiply w/o overflow */
typedef struct logo_node {
NODETYPES node_type;
/* char gc_flags; */
short ref_count;
union {
struct {
struct logo_node *ncar;
struct logo_node *ncdr;
struct logo_node *nobj; /* used only for oblist */
} ncons;
struct {
char *nstring_ptr;
char *nstring_head;
int nstring_len;
} nstring;
struct {
struct logo_node * (*nprim_fun) ();
short npriority;
short nmin_args;
short ndef_args;
short nmax_args;
} nprim;
FIXNUM nint;
FLONUM nfloat;
struct {
int narray_dim;
int narray_origin;
struct logo_node **narray_data;
} narray;
} nunion;
} NODE;
#define settype(node, type) ((node)->node_type = (type))
#define getrefcnt(node) ((node)->ref_count)
#define setrefcnt(node,val) ((node)->ref_count = (val))
#define increfcnt(node) (((node)->ref_count)++)
#define decrefcnt(node) (--((node)->ref_count))
#define n_car nunion.ncons.ncar
#define n_cdr nunion.ncons.ncdr
#define n_obj nunion.ncons.nobj
#define getobject(node) ((node)->n_obj)
#define car(node) ((node)->n_car)
#define cdr(node) ((node)->n_cdr)
#define caar(node) ((node)->n_car->n_car)
#define cadr(node) ((node)->n_cdr->n_car)
#define cdar(node) ((node)->n_car->n_cdr)
#define cddr(node) ((node)->n_cdr->n_cdr)
#define n_str nunion.nstring.nstring_ptr
#define n_len nunion.nstring.nstring_len
#define n_head nunion.nstring.nstring_head
#define getstrptr(node) ((node)->n_str)
#define getstrlen(node) ((node)->n_len)
#define getstrhead(node) ((node)->n_head)
#define setstrptr(node,ptr) ((node)->n_str = (ptr))
#define setstrlen(node,len) ((node)->n_len = (len))
#define setstrhead(node,ptr) ((node)->n_head = (ptr))
#define getstrrefcnt(sh) (*sh)
#define setstrrefcnt(sh, v) (*sh = (v))
#define incstrrefcnt(sh) ((*sh)++)
#define decstrrefcnt(sh) (--(*sh))
#define n_int nunion.nint
#define getint(node) ((node)->n_int)
#define setint(node,num) ((node)->n_int = (num))
#define n_float nunion.nfloat
#define getfloat(node) ((node)->n_float)
#define setfloat(node,num) ((node)->n_float = (num))
#define n_pfun nunion.nprim.nprim_fun
#define n_ppri nunion.nprim.npriority
#define n_pmin nunion.nprim.nmin_args
#define n_pdef nunion.nprim.ndef_args
#define n_pmax nunion.nprim.nmax_args
#define getprimfun(node) ((node)->n_pfun)
#define setprimfun(node,fun) ((node)->n_pfun = (fun))
#define getprimmin(node) ((node)->n_pmin)
#define setprimmin(node,num) ((node)->n_pmin = (num))
#define getprimmax(node) ((node)->n_pmax)
#define setprimmax(no